package com.huike.web.controller.report;


import com.huike.report.domain.vo.IndexBaseInfoVO;
import com.huike.report.domain.vo.IndexTodayInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 首页今日简报
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getBaseInfo(){
        IndexTodayInfoVO todayInfo = reportService.getTodayInfo();
        System.out.println("================"+todayInfo);
        return AjaxResult.success(reportService.getTodayInfo());
    }

    /**
     * 待办事项
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(String beginCreateTime,String endCreateTime){
        //掉用service层的方法进行查询返回数据
        return AjaxResult.success(reportService.getTodoInfo(beginCreateTime,endCreateTime));
    }

    @GetMapping("/report/subjectStatistics/{beginCreateTime}/{endCreateTime}")
    public AjaxResult getsubjectStatistics(@PathVariable String beginCreateTime,@PathVariable String endCreateTime){
        return AjaxResult.success(reportService.getSubjectStatistics(beginCreateTime,endCreateTime));
    }
}